<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>BKI Commands</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.1.2 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="BKI Backend Interface"
HREF="bki.html"><LINK
REL="PREVIOUS"
TITLE="BKI File Format"
HREF="bki-format.html"><LINK
REL="NEXT"
TITLE="Structure of the Bootstrap BKI File"
HREF="bki-structure.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2011-12-01T22:07:59"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.1.2 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="BKI File Format"
HREF="bki-format.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="bki.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 56. <ACRONYM
CLASS="ACRONYM"
>BKI</ACRONYM
> Backend Interface</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="Structure of the Bootstrap BKI File"
HREF="bki-structure.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="BKI-COMMANDS"
>56.2. <ACRONYM
CLASS="ACRONYM"
>BKI</ACRONYM
> Commands</A
></H1
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>create</TT
>
     <TT
CLASS="REPLACEABLE"
><I
>tablename</I
></TT
>
     <TT
CLASS="REPLACEABLE"
><I
>tableoid</I
></TT
>
     [<SPAN
CLASS="OPTIONAL"
><TT
CLASS="LITERAL"
>bootstrap</TT
></SPAN
>]
     [<SPAN
CLASS="OPTIONAL"
><TT
CLASS="LITERAL"
>shared_relation</TT
></SPAN
>]
     [<SPAN
CLASS="OPTIONAL"
><TT
CLASS="LITERAL"
>without_oids</TT
></SPAN
>]
     [<SPAN
CLASS="OPTIONAL"
><TT
CLASS="LITERAL"
>rowtype_oid</TT
> <TT
CLASS="REPLACEABLE"
><I
>oid</I
></TT
></SPAN
>]
     (<TT
CLASS="REPLACEABLE"
><I
>name1</I
></TT
> =
     <TT
CLASS="REPLACEABLE"
><I
>type1</I
></TT
> [<SPAN
CLASS="OPTIONAL"
>,
     <TT
CLASS="REPLACEABLE"
><I
>name2</I
></TT
> = <TT
CLASS="REPLACEABLE"
><I
>type2</I
></TT
>, ...</SPAN
>])</DT
><DD
><P
>      Create a table named <TT
CLASS="REPLACEABLE"
><I
>tablename</I
></TT
>, and having the OID
      <TT
CLASS="REPLACEABLE"
><I
>tableoid</I
></TT
>,
      with the columns given in parentheses.
     </P
><P
>      The following column types are supported directly by
      <TT
CLASS="FILENAME"
>bootstrap.c</TT
>: <TT
CLASS="TYPE"
>bool</TT
>,
      <TT
CLASS="TYPE"
>bytea</TT
>, <TT
CLASS="TYPE"
>char</TT
> (1 byte),
      <TT
CLASS="TYPE"
>name</TT
>, <TT
CLASS="TYPE"
>int2</TT
>,
      <TT
CLASS="TYPE"
>int4</TT
>, <TT
CLASS="TYPE"
>regproc</TT
>, <TT
CLASS="TYPE"
>regclass</TT
>,
      <TT
CLASS="TYPE"
>regtype</TT
>, <TT
CLASS="TYPE"
>text</TT
>,
      <TT
CLASS="TYPE"
>oid</TT
>, <TT
CLASS="TYPE"
>tid</TT
>, <TT
CLASS="TYPE"
>xid</TT
>,
      <TT
CLASS="TYPE"
>cid</TT
>, <TT
CLASS="TYPE"
>int2vector</TT
>, <TT
CLASS="TYPE"
>oidvector</TT
>,
      <TT
CLASS="TYPE"
>_int4</TT
> (array), <TT
CLASS="TYPE"
>_text</TT
> (array),
      <TT
CLASS="TYPE"
>_oid</TT
> (array), <TT
CLASS="TYPE"
>_char</TT
> (array),
      <TT
CLASS="TYPE"
>_aclitem</TT
> (array).  Although it is possible to create
      tables containing columns of other types, this cannot be done until
      after <TT
CLASS="STRUCTNAME"
>pg_type</TT
> has been created and filled with
      appropriate entries.  (That effectively means that only these
      column types can be used in bootstrapped tables, but non-bootstrap
      catalogs can contain any built-in type.)
     </P
><P
>      When <TT
CLASS="LITERAL"
>bootstrap</TT
> is specified,
      the table will only be created on disk; nothing is entered into
      <TT
CLASS="STRUCTNAME"
>pg_class</TT
>,
      <TT
CLASS="STRUCTNAME"
>pg_attribute</TT
>, etc, for it.  Thus the
      table will not be accessible by ordinary SQL operations until
      such entries are made the hard way (with <TT
CLASS="LITERAL"
>insert</TT
>
      commands).  This option is used for creating
      <TT
CLASS="STRUCTNAME"
>pg_class</TT
> etc themselves.
     </P
><P
>      The table is created as shared if <TT
CLASS="LITERAL"
>shared_relation</TT
> is
      specified.
      It will have OIDs unless <TT
CLASS="LITERAL"
>without_oids</TT
> is specified.
      The table's row type OID (<TT
CLASS="STRUCTNAME"
>pg_type</TT
> OID) can optionally
      be specified via the <TT
CLASS="LITERAL"
>rowtype_oid</TT
> clause; if not specified,
      an OID is automatically generated for it.  (The <TT
CLASS="LITERAL"
>rowtype_oid</TT
>
      clause is useless if <TT
CLASS="LITERAL"
>bootstrap</TT
> is specified, but it can be
      provided anyway for documentation.)
     </P
></DD
><DT
><TT
CLASS="LITERAL"
>open</TT
> <TT
CLASS="REPLACEABLE"
><I
>tablename</I
></TT
></DT
><DD
><P
>      Open the table named
      <TT
CLASS="REPLACEABLE"
><I
>tablename</I
></TT
>
      for insertion of data.  Any currently open table is closed.
     </P
></DD
><DT
><TT
CLASS="LITERAL"
>close</TT
> [<SPAN
CLASS="OPTIONAL"
><TT
CLASS="REPLACEABLE"
><I
>tablename</I
></TT
></SPAN
>]</DT
><DD
><P
>      Close the open table.  The name of the table can be given as a
      cross-check, but this is not required.
     </P
></DD
><DT
><TT
CLASS="LITERAL"
>insert</TT
> [<SPAN
CLASS="OPTIONAL"
><TT
CLASS="LITERAL"
>OID =</TT
> <TT
CLASS="REPLACEABLE"
><I
>oid_value</I
></TT
></SPAN
>] <TT
CLASS="LITERAL"
>(</TT
> <TT
CLASS="REPLACEABLE"
><I
>value1</I
></TT
> <TT
CLASS="REPLACEABLE"
><I
>value2</I
></TT
> ... <TT
CLASS="LITERAL"
>)</TT
></DT
><DD
><P
>      Insert a new row into the open table using <TT
CLASS="REPLACEABLE"
><I
>value1</I
></TT
>, <TT
CLASS="REPLACEABLE"
><I
>value2</I
></TT
>, etc., for its column
      values and <TT
CLASS="REPLACEABLE"
><I
>oid_value</I
></TT
> for its OID.  If
      <TT
CLASS="REPLACEABLE"
><I
>oid_value</I
></TT
> is zero
      (0) or the clause is omitted, and the table has OIDs, then the
      next available OID is assigned.
     </P
><P
>      NULL values can be specified using the special key word
      <TT
CLASS="LITERAL"
>_null_</TT
>.  Values containing spaces must be
      double quoted.
     </P
></DD
><DT
><TT
CLASS="LITERAL"
>declare</TT
> [<SPAN
CLASS="OPTIONAL"
><TT
CLASS="LITERAL"
>unique</TT
></SPAN
>]
     <TT
CLASS="LITERAL"
>index</TT
> <TT
CLASS="REPLACEABLE"
><I
>indexname</I
></TT
>
     <TT
CLASS="REPLACEABLE"
><I
>indexoid</I
></TT
>
     <TT
CLASS="LITERAL"
>on</TT
> <TT
CLASS="REPLACEABLE"
><I
>tablename</I
></TT
>
     <TT
CLASS="LITERAL"
>using</TT
> <TT
CLASS="REPLACEABLE"
><I
>amname</I
></TT
>
     <TT
CLASS="LITERAL"
>(</TT
> <TT
CLASS="REPLACEABLE"
><I
>opclass1</I
></TT
>
     <TT
CLASS="REPLACEABLE"
><I
>name1</I
></TT
>
     [<SPAN
CLASS="OPTIONAL"
>, ...</SPAN
>] <TT
CLASS="LITERAL"
>)</TT
></DT
><DD
><P
>      Create an index named <TT
CLASS="REPLACEABLE"
><I
>indexname</I
></TT
>, having OID
      <TT
CLASS="REPLACEABLE"
><I
>indexoid</I
></TT
>,
      on the table named
      <TT
CLASS="REPLACEABLE"
><I
>tablename</I
></TT
>, using the
      <TT
CLASS="REPLACEABLE"
><I
>amname</I
></TT
> access
      method.  The fields to index are called <TT
CLASS="REPLACEABLE"
><I
>name1</I
></TT
>, <TT
CLASS="REPLACEABLE"
><I
>name2</I
></TT
> etc., and the operator
      classes to use are <TT
CLASS="REPLACEABLE"
><I
>opclass1</I
></TT
>, <TT
CLASS="REPLACEABLE"
><I
>opclass2</I
></TT
> etc., respectively.
      The index file is created and appropriate catalog entries are
      made for it, but the index contents are not initialized by this command.
     </P
></DD
><DT
><TT
CLASS="LITERAL"
>declare toast</TT
>
     <TT
CLASS="REPLACEABLE"
><I
>toasttableoid</I
></TT
>
     <TT
CLASS="REPLACEABLE"
><I
>toastindexoid</I
></TT
>
     <TT
CLASS="LITERAL"
>on</TT
> <TT
CLASS="REPLACEABLE"
><I
>tablename</I
></TT
></DT
><DD
><P
>      Create a TOAST table for the table named
      <TT
CLASS="REPLACEABLE"
><I
>tablename</I
></TT
>.
      The TOAST table is assigned OID
      <TT
CLASS="REPLACEABLE"
><I
>toasttableoid</I
></TT
>
      and its index is assigned OID
      <TT
CLASS="REPLACEABLE"
><I
>toastindexoid</I
></TT
>.
      As with <TT
CLASS="LITERAL"
>declare index</TT
>, filling of the index
      is postponed.
     </P
></DD
><DT
><TT
CLASS="LITERAL"
>build indices</TT
></DT
><DD
><P
>      Fill in the indices that have previously been declared.
     </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="bki-format.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="bki-structure.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><ACRONYM
CLASS="ACRONYM"
>BKI</ACRONYM
> File Format</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="bki.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Structure of the Bootstrap <ACRONYM
CLASS="ACRONYM"
>BKI</ACRONYM
> File</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>